import {HOMEDATA} from '../mutations_type.js'
import {getSiteConfig} from "../../api/index.js";
;

const home = {
  state: {
    swap: null,
    homedata: null,
    aprove_address: null,
    usdt_address: null,
    chain: null,
    app_id: null,
    web_url: localStorage.getItem("web_url")
      ? localStorage.getItem("web_url")
      : null,
  },
  mutations: {
    [HOMEDATA](
      state,
      { aprove_address, usdt_address, chain, app_id, home_data, swap, web_url },
    ) {
      state.aprove_address = aprove_address;
      state.usdt_address = usdt_address;
      state.chain = chain;
      state.app_id = app_id;
      state.swap = swap;
      state.homedata = home_data;
      state.web_url = web_url;
      localStorage.setItem("web_url", state.web_url);
    },
  },
  getters: {},
  actions: {
    gethomedata({ commit }) {
      getSiteConfig().then(res => {
        // console.log(res)
        commit(HOMEDATA, res);
      });
    },
  },
};
export default home